import wx

class ConnectionDialog(wx.Dialog):
    def __init__(self, parent, id=-1, title='Connection', size=(340,160),style=wx.CLOSE_BOX | wx.CAPTION):
        wx.Dialog.__init__(self, parent=parent, id=id, title=title, size=size, style=style)
        
        self.AddressStaticText = wx.StaticText(self, -1, "Address", pos=(5, 10))
        self.AddressTextCtrl = wx.TextCtrl(self, -1, "127.0.0.1", size=(140,-1), pos=(80, 5))
        self.PortStaticText = wx.StaticText(self, -1, "Port", pos=(230, 10))
        self.PortTextCtrl = wx.TextCtrl(self, -1, "14120", size=(60,-1), pos=(265, 5))
        self.NickStaticText = wx.StaticText(self, -1, "Nickname", pos=(5, 50))
        self.NickTextCtrl = wx.TextCtrl(self, -1, "n00b", size=(140,-1), pos=(80, 45))
        self.OkButton = wx.Button(self, wx.ID_OK, pos=(240,85))
        self.CancelButton = wx.Button(self, wx.ID_CANCEL, pos=(140,85))
    
    def GetValues(self):
        vars = []
        vars.append(self.AddressTextCtrl.GetValue())
        vars.append(self.PortTextCtrl.GetValue())
        vars.append(self.NickTextCtrl.GetValue())
        return vars


class ListenDialog(wx.Dialog):
    def __init__(self, parent, id=-1, title='Listen', size=(340,160),style=wx.CLOSE_BOX | wx.CAPTION):
        wx.Dialog.__init__(self, parent=parent, id=id, title=title, size=size, style=style)
        
        self.NickStaticText = wx.StaticText(self, -1, "Nickname", pos=(5, 10))
        self.NickTextCtrl = wx.TextCtrl(self, -1, "n00b", size=(140,-1), pos=(80, 5))
        self.PortStaticText = wx.StaticText(self, -1, "Port", pos=(230, 10))
        self.PortTextCtrl = wx.TextCtrl(self, -1, "14120", size=(60,-1), pos=(265, 5))
        self.OkButton = wx.Button(self, wx.ID_OK, pos=(240,85))
        self.CancelButton = wx.Button(self, wx.ID_CANCEL, pos=(140,85))
    
    def GetValues(self):
        vars = []
        vars.append(self.PortTextCtrl.GetValue())
        vars.append(self.NickTextCtrl.GetValue())
        return vars
    
class AdvancedSearch(wx.Dialog):
    def __init__(self, parent, id = -1, title = 'Advanced Search', size = (400,485)):
        wx.Dialog.__init__(self, parent = parent, id = id, title = title, size = size)
        
        wx.StaticBox(self, -1, 'Advanced Search', pos = (5,5), size = (385,445))
        
        # Nome Carta
        self.CardNameStatic = wx.StaticText(self, -1, 'Card Name: ', pos = (12,30))
        self.CardNameCtrl = wx.TextCtrl(self, -1, '', pos = (85,25), size = (140,-1))
        
        # Attributo Carta
        lista = ['','Monster','Spell','Trap']
        self.CardAttributeStatic = wx.StaticText(self, -1, 'Card Type: ', pos = (12,60))
        self.CardAttributeChoice = wx.Choice(self, -1, pos = (84,55), size = (80,-1), choices = lista)
        
        wx.StaticBox(self, -1, 'If Spell or Trap...', pos = (10,90), size=(370,60))
        
        # Tipo2
        lista = ['','Continuos Trap','Counter Trap','Continuos Spell','Counter Spell',
                'Quick-Play Spell','Equip Spell','Field Spell']
        self.CardType2Static = wx.StaticText(self, -1, 'Spell or Trap SubType: ', pos = (15, 117))
        self.CardType2Choice = wx.Choice(self, -1, pos=(134,112), size=(80,-1), choices=lista)
        
        wx.StaticBox(self,-1,'If Monster...', pos = (10,160),size=(370,145))
        
        # Tipo di mostro
        self.MonsterType = wx.RadioButton(self, -1, 'Any', pos =(15,180), style = wx.RB_GROUP)
        self.MonsterType = wx.RadioButton(self, -1, 'Normal',pos=(55,180))
        self.MonsterType = wx.RadioButton(self,-1,'Effect',pos=(115,180))
        self.MonsterType = wx.RadioButton(self,-1,'Fusion',pos=(175,180))
        self.MonsterType = wx.RadioButton(self, -1,'Ritual',pos=(235,180))
        
        
        
        # Tipo Carta
        lista = ['','Light','Dark','Earth','Wind','Fire']
        self.CardTypeStatic = wx.StaticText(self, -1, 'Monster type: ', pos = (15, 215))
        self.CardTypeChoice = wx.Choice(self, -1, pos = (85,210), size=(80,-1), choices = lista)
        
        
        # Stelle
        lista = ['','1','2','3','4','5','6','7','8','9','10','11','12']
        self.CardStarsStatic = wx.StaticText(self, -1, 'Stars: >=', pos = (175,215))
        self.CardStarsChoice = wx.Choice(self, -1, pos = (225,210), size =(40,-1), choices=lista)
        self.CardStarsStatic2 = wx.StaticText(self, -1, 'and <', pos=(270,215))
        self.CardStarsChoice2 = wx.Choice(self, -1, pos=(300,210), size = (40,-1),choices=lista)
        
        # Atk/Def
        self.MonsterAtkStatic = wx.StaticText(self,-1,'Atk: >=',pos=(15,250))
        self.MonsterAtkSpin = wx.SpinCtrl(self, -1, '0',pos=(60,245),size=(60,-1),min=0,max=5000)
        self.MonsterAtkStatic2 = wx.StaticText(self,-1,'and <',pos=(130,250))
        self.MonsterAtkSpin2 = wx.SpinCtrl(self,-1,'0',pos=(170,245),size=(60,-1),min=0,max=5000)
        
        self.MonsterDefStatic = wx.StaticText(self,-1,'Def: >=',pos=(15,280))
        self.MonsterDefSpin = wx.SpinCtrl(self, -1,'0',pos =(60,275), size = (60,-1),min=0,max=5000)
        self.MonsterDefStatic2 = wx.StaticText(self,-1,'and <',pos=(130,280))
        self.MonsterDefSpin2 = wx.SpinCtrl(self, -1,'0',pos =(170,275), size = (60,-1),min=0,max=5000)
        
        wx.StaticBox(self,-1,'Card Effect', pos = (10,310), size=(370,90))
        
        # Effetto
        wx.CardEffect = wx.TextCtrl(self,-1, pos=(30,330),size=(320,60),style = wx.TE_MULTILINE)
        
        # Bottoni
        self.ResetButton = wx.Button(self,-1, 'Reset All Fields',pos=(30,415),size=(-1,-1))
        #self.ResetButton = wx.Button(self,-1,wx.ID_REFRESH,'Reset Fields',pos=(30,415),size=(-1,-1))
        self.CancelButton = wx.Button(self,wx.ID_CANCEL,pos=(160,415),size=(-1,-1))
        self.SearchButton = wx.Button(self,-1,'Search',pos=(280,415),size=(-1,-1))
        
        #self.ResetButton.Bind(wx.EVT_BUTTON,self.ResetFields,-1)
        def ResetFields(self):
            self.CardNameCtrl.SetValue('')
            self.CardTypeChoice.SetValue('Any')
            self.MonsterAtkSpin.SetValue(0)
            self.MonsterAtkSpin2.SetValue(0)
            self.MonsterDefSpin.SetValue(0)
            self.MonsterDefSpin2.SetValue(0)
        
        def GetCardName(self):
            CardName = self.CardNameCtrl.GetValue()
            return CardName
        
        def GetCardAttribute(self):
            CardAttribute = self.CardAttributeChoice.GetCurrentSelection()
            return CardAttribute
        
        def GetCardType2(self):
            CardType2 = self.CardType2Choice.GetCurrentSelection()
            return CardType2
        
        def GetMonsterType(self):
            MonsterType = self.MonsterType.GetValue()
            return MonsterType
        
        def GetCardType(self):
            CardType = self.CardTypeChoice.GetCurrentSelection()
            return CardType
        
        def GetStars(self):
            Stars = self.CardStarsChoice.GetCurrentSelection()
            return Stars
        
        def GetMonsterAtk(self):
            MinAtk = self.MonsterAtkSpin.GetValue()
            MaxAtk = self.MonsterAtkSpin2.GetValue()
            return MinAtk, MaxAtk
        
        def GetMonsterDef(self):
            MinDef = self.MonsterDefSpin.GetValue()
            MaxDef = self.MonsterDefSpin2.GetValue()
            return MinDef, MaxDef
        